package com.situ.day27.reflect;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.IOException;
import java.lang.String;
import java.util.Properties;

public class DBDemo {

    public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        // List list = new ArrayList();
        // MySql mySql = new MySql();
        // mySql.getConnection();
        // IDB db = new Oracle();
        // db.getConnection();

        FileInputStream fileInputStream = new FileInputStream("db.properties");
        //FileInputStream fileInputStream = new FileInputStream("D:\\Idea210702\\JavaStudy\\JavaSE\\db.properties");
        Properties properties = new Properties();
        properties.load(fileInputStream);
        String className = properties.getProperty("className");
        System.out.println(className);

        Class clazz = Class.forName(className);
        IDB db = (IDB) clazz.newInstance();
        db.getConnection();



    }

    @Test
    public void test33() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
        IDB db = DBFactory.createDB();
        db.getConnection();
    }
}
